﻿
using Xacml.Core.Interfaces;
using Xacml.Core.Runtime;

namespace Xacml.Core.Runtime.Functions
{
  public class DayTimeDurationEqual : BaseEqual
  {
    public override string Id
    {
      get
      {
        return "urn:oasis:names:tc:xacml:1.0:function:dayTimeDuration-equal";
      }
    }

    public override IDataType DataType
    {
      get
      {
        return (IDataType) DataTypeDescriptor.DayTimeDuration;
      }
    }

    public override EvaluationValue Evaluate(EvaluationContext context, params IFunctionParameter[] args)
    {
      try
      {
        if (this.GetDayTimeDurationArgument(args, 0).Equals((object) this.GetDayTimeDurationArgument(args, 1)))
          return EvaluationValue.True;
        return EvaluationValue.False;
      }
      catch (EvaluationException ex)
      {
        context.Trace("ERR: {0}", (object) ex.Message);
        return EvaluationValue.False;
      }
    }
  }
}
